package com.mikeli.javacourse.lesson3.practice;

public class ThreadTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            System.out.println("当前线程->" + Thread.currentThread().getName());
        });
        thread.setDaemon(true);
        thread.setName("test Thread");
        thread.start();
//        thread.sleep(5000);

        testSleep();
    }

    public static void testSleep(){
        Object o = new Object();
        new Thread(()->{
            synchronized (o){
                try {
                    System.out.println("thread 1 start");
                    Thread.sleep(1000);
                    System.out.println("thread 1 end ");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }).start();
        new Thread(()->{
            synchronized (o){
                System.out.println("thread 2 start");
                System.out.println("thread 2 end");
            }

        }).start();

    }
}
